<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        .green {color: green;}
        .red {color: #f00;}
    </style>
</head>
<body>
    <div id="app">
    </div>
    <script src="../node_modules/vue/dist/vue.js"></script>
    <script>
        new Vue({
            el: '#app',
            template: `
                    <div class="box">
                        <p class="green" v-bind:class="{ red:isRed }">我是文本</p>
                        <button v-on:click='changeColor'>切换字体的颜色</button>
                    </div>
                    `,
            data() {
                return {
                    msg: "red",
                    isRed: true,
                }
            },
            methods: {
                changeColor() {
                    this.isRed = !this.isRed
                },
                changeColor:function(){
                    this.isRed=!this.isRed
                }
            }
        })
    </script>
</body>

</html>